// 登录相关的mock数据

// 模拟HTTP请求延迟
const delay = (ms = 300) => {
  return new Promise(resolve => setTimeout(resolve, ms));
};

// 模拟用户信息数据
const mockUserInfo = {
  userId: '1001',
  userName: '张同学',
  avatarUrl: 'https://zxs-lyblog.oss-cn-hangzhou.aliyuncs.com/user-header/user_header.png',
  phoneNumber: '138****1234',
  collect: '45',
  fans: '128',
  visit: '567',
  signature: '专注前端开发，热爱技术分享',
  level: 'LV.3',
  joinTime: '2023-06-15'
};

// 模拟登录成功返回的token
const mockToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMDAxIiwidXNlck5hbWUiOiLlvKDkuJrlsI_nm7Toh6Hoh60iLCJpYXQiOjE3MTkwODQ0NTYsImV4cCI6MTcxOTE3MDg1Nn0.5r8wFpU7sK5i0jE9fR2aB3cD4eG7hJ6kL8mN9pQ0sX';

/**
 * 模拟微信登录接口
 * @param {string} code - 微信登录code
 * @returns {Promise} - 返回登录结果
 */
export const mockWechatLogin = async (code) => {
  // 模拟网络延迟
  await delay();
  
  // 模拟登录成功，返回token
  return {
    code: 0,
    message: '登录成功',
    data: {
      token: mockToken
    }
  };
};

/**
 * 模拟获取用户信息接口
 * @param {string} token - 用户token
 * @returns {Promise} - 返回用户信息
 */
export const mockGetUserInfo = async (token) => {
  // 模拟网络延迟
  await delay();
  
  // 验证token（简单模拟）
  if (token && token === mockToken) {
    return {
      code: 0,
      message: '获取成功',
      data: mockUserInfo
    };
  } else {
    return {
      code: -1,
      message: 'token无效或已过期',
      data: null
    };
  }
};